<?php
set_include_path("../include;include");
require_once '/model/Event.php';
require_once '/dao/CodeKeeperDAO.php';

class CodeKeeper {
	
	
	function __construct() {
		
	}
	
	public static function generateCode(Event $event) {
		$prefix = $event->getPrefix();
		$counter = self::getCount($event->getId());
		$counter = self::increment($event->getId());
		return $prefix."-".$counter;
	}
	
	private static function getCount(integer $eventkey) {
		$dao = CodeKeeperDAO::getInstance();
		
		return $dao->getCallvalueByEventkey($eventkey);
	}
	
	private static function increment(integer $eventkey) {
		$dao = CodeKeeperDAO::getInstance();
		
		return $dao->incrementCallvalueForEventKey($eventkey);
	}
}

?>